{%load pgfilters%}
<form class="form-horizontal" method="post" action=".">{%if not nocsrf%}{% csrf_token %}{%endif%}
  {%if form.errors %}
    <div class="alert alert-danger">
      Please correct the errors below, and re-submit the form.
    </div>
  {%endif%}
{%if form.fieldsets%}
{%for fieldset in form.fieldsets%}
<fieldset id="{{fieldset.id}}" class="form-group">
  <legend>{{fieldset.legend}}</legend>
{%if fieldset.description%}<p>{{fieldset.description}}</p>{%endif%}
{%for field in fieldset.fields%}
  {%include "base/form_field.html" with field=form|keylookup:field %}
{%endfor%}
</fieldset>
{%endfor%}
{%else%}
  {% for field in form %}
{%include "base/form_field.html" %}
  {%endfor%}
{%endif%}
  <button type="submit" class="btn btn-primary">{{savebutton|default:"Save"}}</button>
</form>
